package com.ctshk.rpc.tour.mapper;

import java.util.List;

import com.ctshk.rpc.tour.dto.cache.TripGroup;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ctshk.common.service.mapper.CtsBaseMapper;
import com.ctshk.rpc.tour.dto.SeriesTripDTO;
import com.ctshk.rpc.tour.dto.cache.TripsGroupDTO;
import com.ctshk.rpc.tour.entity.SeriesTrip;

/**
 * <p>
 * 系列团行程 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-12
 */
public interface SeriesTripMapper extends CtsBaseMapper<SeriesTrip> {


    @Select({
            "SELECT id,title,cover_photo_url,gmt_modified",
            "FROM t_series_trip ",
            "WHERE tour_type_id = #{id} "
    })
    List<SeriesTripDTO> getTripsByStatus(@Param("id") Long id, @Param("status") Integer status);

    @Select({
            "SELECT id,title,cover_photo_url url,gmt_create ",
            "FROM t_series_trip ",
            "ORDER BY gmt_create DESC ",
            "LIMIT 0,5"
    })
    List<TripsGroupDTO> getTrips();

    @Select({
            "SELECT id,cover_photo_url,title,gmt_modified FROM t_series_trip ",
            "WHERE tour_type_id = #{id} AND is_deleted = 0"
    })
    List<TripGroup> getTripsByGroupId(Long id);

    @Select({
            "SELECT * FROM t_series_trip ",
            "WHERE is_deleted = '0'"
    })
    List<SeriesTrip> getTripsAll();


    @Select({
            "<script>",
            "SELECT destination_id FROM t_series_trip ",
            "WHERE is_deleted = 0 AND STATUS = 3 ",
            "AND destination_id IN ",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    List<Long> getDestinationIdByExsitTrip(@Param("ids") List<Long> ids);
}
